package com.samoiloff.ui.btns {
	import com.samoiloff.owncrosswords.viewers.classic.model.WordItem;
	import assets.BtnDnBmdt;
	import assets.BtnOverBmdt;
	import assets.BtnUpBmdt;

	import org.bytearray.display.ScaleBitmap;

	import flash.display.BitmapData;
	import flash.geom.Rectangle;

	/**
	 * @author NM Group
	 */
	public class BtnBg extends ScaleBitmap {
		
		public static const UP		: int = 1;
		public static const OVER	: int = 2;
		public static const DOWN	: int = 3;
		
		private var _frame:int;
		
		private var _width:Number;
		
		public function BtnBg() {
			super(new BtnUpBmdt());
			scale9Grid = new Rectangle(10,10,70,5);
			frame = UP;
		}
		
		override public function set width(width:Number):void {
			_width = width;
			super.width = _width;
		}

		public function set frame(frame:int):void {
			if (_frame != frame) {
				_frame = frame;
				var bmdt:BitmapData;
				switch (_frame) {
					case UP :  bmdt = new BtnUpBmdt(); break;
					case OVER : bmdt = new BtnOverBmdt(); break;
					case DOWN : bmdt = new BtnDnBmdt(); break; 
				}
				bitmapData = bmdt;
				if (!isNaN(_width)) {
					super.width = _width;
				}
				bmdt.dispose();
			}
		}
		
		public function destroy():void {
			
		}
	}
}
